package org.jasper.impl.module;

import org.jasper.api.container.ReleaseId;
import org.jasper.api.knowledge.KnowledgeBuilder;
import org.jasper.api.knowledge.KnowledgePackage;
import org.jasper.api.module.InternalKieModule;
import org.jasper.api.module.KieModuleModel;
import org.jasper.api.project.KieProject;
import org.jasper.impl.base.KieBaseModelImpl;
import org.jasper.impl.utils.ResultsImpl;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by OP038074 on 2018/7/20.
 */
public abstract class AbstractKieModule implements InternalKieModule {

    protected final ReleaseId releaseId;

    private final KieModuleModel kModuleModel;

    private final Map<String, KnowledgeBuilder> kBuilders = new HashMap<String, KnowledgeBuilder>();

    public AbstractKieModule(ReleaseId releaseId, KieModuleModel kModuleModel) {
        this.releaseId = releaseId;
        this.kModuleModel = kModuleModel;
    }

    public ReleaseId getReleaseId() {
        return releaseId;
    }

    public static KnowledgeBuilder buildKnowledgePackages( KieBaseModelImpl kBaseModel,
                                                           KieProject kieProject,
                                                           ResultsImpl messages ) {
        return null;
    }

    public Collection<KnowledgePackage> getKnowledgePackagesForKieBase(String kieBaseName) {
        KnowledgeBuilder kbuilder = kBuilders.get(kieBaseName);
        return kbuilder != null ? kbuilder.getKnowledgePackages() : null;
    }
}
